import http from 'Utils/http'
import * as type from './type'
const actions = {
    // 获得热映数据
    async getNowHot({ commit }, value) { // 传入{ commit }对象，就可以包含 url, method, params, header
        let result = await http({
            url: `/maoyan/ajax/${value}`,
            method: 'get',
            params: {
                token: ''
            }
        })

        let action = {
            type: type.MODIFY_N_HOTS,
            payload: result.data
        }

        commit(action)
    },
    // 获取即将上映轮播数据
    async getExpected({ commit }) {
        let result = await http({
            url: '/maoyan/ajax/mostExpected',
            method: 'get',
            params: {
                ci: 10,
                limit: 10,
                offset: 0,
                token: ''
            }
        })

        let action = {
            type: type.MODIFY_MOST_EXPECTED,
            payload: result.data.coming
        }

        commit(action)
    }
}

export default actions